//! @Author: DengLibin
//! @Date: Create in 2024-06-12 11:28:47
//! @Description:  将大写字母变小写字母并且前面加下划线

pub fn convert_lower_string(input: &str) -> String {
    let mut result = String::new();

    for c in input.chars() {
        if c.is_uppercase() {
            result.push('_');
            result.push(c.to_ascii_lowercase());
        } else {
            result.push(c);
        }
    }

    result
}

/// @Author: DengLibin
/// @Date: Create in 2024-07-16 10:41:38
/// @Description: 是否包含中文
pub fn contains_chinese(s: &str) -> bool {
    for c in s.chars() {
        if (c >= '\u{4E00}' && c <= '\u{9FFF}') || // CJK Unified Ideographs
           (c >= '\u{3400}' && c <= '\u{4DBF}') || // CJK Unified Ideographs Extension A
           (c >= '\u{20000}' && c <= '\u{2A6DF}') || // CJK Unified Ideographs Extension B
           (c >= '\u{2A700}' && c <= '\u{2B73F}') || // CJK Unified Ideographs Extension C
           (c >= '\u{2B740}' && c <= '\u{2B81F}') || // CJK Unified Ideographs Extension D
           (c >= '\u{2B820}' && c <= '\u{2CEAF}') || // CJK Unified Ideographs Extension E
           (c >= '\u{F900}' && c <= '\u{FAFF}') || // CJK Compatibility Ideographs
           (c >= '\u{2F800}' && c <= '\u{2FA1F}') { // CJK Compatibility Ideographs Supplement
            return true;
        }
    }
    false
}


